package com.cloudkinto.common.common;

import com.wf.captcha.ArithmeticCaptcha;
import com.wf.captcha.SpecCaptcha;
import com.wf.captcha.base.Captcha;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
 * @author zhangyy
 * @date 2020/6/23 9:56
 * @description: 生成验证码
 */
public class VerificationCodeUtil {


    // 算术类型
    public static Map generateCode() {
        //字符验证码
        SpecCaptcha captcha = new SpecCaptcha (111, 36);
        // 几位数运算，默认是两位
        captcha.setLen(4);
        //纯数字
        captcha.setCharType(Captcha.TYPE_ONLY_NUMBER);
        // 获取运算的结果
        String result = captcha.text();

        Map map = new HashMap();
        map.put("img", captcha.toBase64());
        map.put("result", result);
        return map;
    }

}
